import axios from 'axios';
import {message} from 'antd';

axios.defaults.baseURL = 'https://gank.io';
axios.defaults.headers.common['Authorization'] = encodeURI('略略略');


// 添加一个请求拦截器
axios.interceptors.request.use(function (config) {
  // Do something before request is sent
  return config;
}, function (error) {
  // Do something with request error
  return Promise.reject(error);
});

// 添加一个响应拦截器
axios.interceptors.response.use(function (response) {
  // Do something with response data
  if (response.status === 200) {
    if (!response.error) {
      message.success('ok');
      return response;
    } else {
      message.error('gank io error');
    }
  } else {
    message.error('status' + response.status);
  }

}, function (error) {
  // Do something with response error
  return Promise.reject(error);
});
